home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
LIBRARY
/
PASCALL
/
TEMPJUNK
/
FERNSCOL.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-10-05
|
2KB
|
84 lines
program payroll;
{sample ineractive processing program}
uses
crt;
const
tax=25.00;
stringsize=20;
blank=' ';
type
fnmesz=packed array [1..stringsize] of char;
function gross(hours:integer;rate:real):real;
begin
gross:=hours*rate;
end;
function net(gross,tax:real):real;
begin
net:=gross-tax;
end;
procedure preset(var myfile:text; filename:fnmesz);
begin
assign(myfile,filename);
reset(myfile);
clrscr;
end;
procedure input(var myfile:text;var hours:integer;var rate:real);
begin
readln(myfile,hours);
readln(myfile,rate);
end;
function inputvalid(hours:integer;rate:real):boolean;
begin
if (hours>40) and (hours<20) then inputvalid:=false;
if (rate>50) and (rate<1) then inputvalid:=false;
end;
procedure output(emp,hours:integer;rate:real);
begin
if (inputvalid(hours,rate)) then
begin
writeln;
writeln('Employee #',emp);
writeln(' Hours worked are ',hours);
writeln(' Hourly rate is $',rate:5:2);
writeln(' Gross pay is $',gross(hours,rate):7:2);
writeln(' Net pay is $',net(gross(hours,rate),tax):7:2);
end
else begin
writeln;
writeln('Employee #',emp);
writeln(' HAS A RECORD INVALID ACCORDING TO COMPANY RULES');
writeln(' PLEASE CHECK');
end;
readln;
clrscr;
end;
procedure go;
var
hours, emp:integer;
rate : real;
fnme:fnmesz;
myfile:text;
begin
fnme:='a:\set.pas ';
preset(myfile,fnme);
emp:=0;
while not eof(myfile) do
begin
emp:=emp+1;
input(myfile,hours,rate);
output(emp,hours,rate);
end;
close(myfile);
end;
begin
go;
end.